package com.gitee.fastmybatis.core.query;

/**
 * LambdaQuery
 * <pre>
 * {@literal
 * LambdaQuery<User> query = new LambdaQuery<>();
 * query.eq(User::getUserName, "111");
 *
 * LambdaQuery<User> query1 = LambdaQuery.create(User.class)
 *          .eq(User::getUserName, "222")
 *          .eq(User::getId, 2);
 * }
 * </pre>
 * @param <T>
 * @author tanghc
 */
public class LambdaQuery<T> extends Query implements LambdaConditionAnd<LambdaQuery<T>, T>, LambdaConditionOr<LambdaQuery<T>, T> {

    public static <T> LambdaQuery<T> create(Class<T> clazz) {
        return new LambdaQuery<>();
    }

    public LambdaQuery<T> andLambda(LambdaConditionChain<T> conditionChain) {
        this.getCondition().subCondition(Joint.AND, conditionChain.apply(new LambdaCondition<>()));
        return this;
    }

    public LambdaQuery<T> orLambda(LambdaConditionChain<T> conditionChain) {
        this.getCondition().subCondition(Joint.OR, conditionChain.apply(new LambdaCondition<>()));
        return this;
    }

}
